//package com.zonhar.autofeed.controller;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//import uk.co.caprica.picam.*;
//import uk.co.caprica.picam.enums.AutomaticWhiteBalanceMode;
//import uk.co.caprica.picam.enums.Encoding;
//import static uk.co.caprica.picam.CameraConfiguration.cameraConfiguration;
//import javax.imageio.ImageIO;
//import java.awt.image.BufferedImage;
//import java.io.*;
//
//@RestController
//@RequestMapping("/pca")
//public class PcaController {
//
//    private final static Logger log = LoggerFactory.getLogger(PcaController.class);
//
//
//    @RequestMapping(value = "/run", produces = MediaType.IMAGE_PNG_VALUE)
//    @ResponseBody
//    public byte[] getImage() throws IOException {
//        String filename = "test.jpg";
//        CameraConfiguration config = cameraConfiguration()
//                .width(1920)
//                .height(1080)
//                .automaticWhiteBalance(AutomaticWhiteBalanceMode.AUTO)
//
//                .encoding(Encoding.PNG)
//                .quality(85);
//
//        try (Camera camera = new Camera(config)) {
//            ByteArrayPictureCaptureHandler byteArrayPictureCaptureHandler =new ByteArrayPictureCaptureHandler();
//            camera.takePicture(byteArrayPictureCaptureHandler);
//            byte[] result = byteArrayPictureCaptureHandler.result();
//
//            return result;
//
//        } catch (CaptureFailedException e) {
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//       return null;
//    }
//
//
//    /**
//     * 将BufferedImage转换为byte[]
//     * @param image
//     * @return
//     */
//    public byte[] bufferedImageToByteArray(BufferedImage image) throws IOException{
//        ByteArrayOutputStream os = new ByteArrayOutputStream();
//        ImageIO.write(image, "png", os);
//        return os.toByteArray();
//    }
//
//
////    class MyHCSR501Handler implements IHCSR501Handler {
////        private final Logger LOG = LoggerFactory.getLogger(MyHCSR501Handler.class);
////
////        private static final String dateFormat = "yyyy-MM-dd HH:mm:ss.SSS";
////        private  final SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
////
////        @Override
////        public void handle(String pinName, boolean detect, Date date) {
////            LOG.info("[{}] {} {}", pinName, detect, sdf.format(date));
////        }
////    }
//
//}
